package com.smart.seven.aop.pointcutadvisor.composable;

import org.springframework.aop.Pointcut;
import org.springframework.aop.support.ComposablePointcut;
import org.springframework.aop.support.ControlFlowPointcut;
import org.springframework.aop.support.NameMatchMethodPointcut;

/**
 * 复合切点
 *
 * @author junrui.wang
 * @create 2019/3/14
 */
public class GreetingComposablePointcut {
    public Pointcut getIntersectionPointcut(){
        ComposablePointcut composablePointcut = new ComposablePointcut();
        //创建流程切点
        Pointcut controlFlowPointcut = new ControlFlowPointcut(WaiterDelegate.class, "service");

        //创建方法名切点
        NameMatchMethodPointcut nameMatchMethodPointcut = new NameMatchMethodPointcut();
        nameMatchMethodPointcut.addMethodName("greetTo");

        //返回流程切点和方法名切点的交集
        return composablePointcut.intersection(controlFlowPointcut).intersection((Pointcut) nameMatchMethodPointcut);
    }
}
